package com.tengju.bff.interfaces.covercharge.util.MqTimeUtil;

/**
 * @author liang_shi
 * @date 2020/7/16 11:34
 * @description 会员入星延迟消费时间
 */
public class AddStartDelayTimeUtil {

    private static final int[] DELAY_TIME = {
            minutes(0),
            minutes(1),
            minutes(5),
            minutes(15),
            minutes(30),
    };

    /**
     * 通知频率：根据已通知的次数来计算下次通知的延时毫秒数
     * （通知的间隔频率一般是：1m,5m,15m,30m）；
     *
     * @param pushCount 已推送次数
     * @return 下次推送延迟时间 单位: 毫秒
     */
    public static int getDelay(int pushCount) {
        pushCount = Math.min(Math.max(pushCount, 0), DELAY_TIME.length - 1);
        return DELAY_TIME[pushCount];
    }

    private static int seconds(int seconds) {
        return seconds * 1000;
    }

    private static int minutes(int minutes) {
        return minutes * 60 * 1000;
    }

    private static int hours(int hours) {
        return hours * 60 * 60 * 1000;
    }

    private static int days(int days) {
        return days * 24 * 60 * 60 * 1000;
    }


    public static void main(String[] args) {
        String a = 1 + "_" + 3;
        System.out.println(a.split("_")[0]);
        System.out.println(getDelay(4));
    }
}
